package com.pz.gulimall.product.service.impl;

import com.pz.gulimall.product.dao.CategoryDao;
import com.pz.gulimall.product.entity.CategoryEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class CacheService {
    @Autowired
    private CategoryDao categoryDao;
    @Cacheable(value = "categories", key = "#root.methodName", sync = true)
    public List<CategoryEntity> getCategoriesWithSpringCache(){
        return categoryDao.selectList(null);
    }
}
